package org.zachary.commonservice.strategy.factory;

import org.springframework.stereotype.Component;
import org.zachary.commonservice.entity.ServiceType;
import org.zachary.commonservice.strategy.CreditStrategy;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Component
public class StrategyRegistry {
    public  final Map<ServiceType, CreditStrategy> registry = new ConcurrentHashMap<>();

    public void register(ServiceType type, CreditStrategy strategy) {
        registry.put(type, strategy);
    }

    public CreditStrategy getStrategy(ServiceType type) {
        return registry.get(type);
    }
}